namespace Gauss {
	static const int N = 305;
	static const double eps = 1e-8;

	double A[N][N]; 
	int Gauss(int n, int m) {
		int i = 0, x = 0;
		for (; i < n && x < m; i++, x++) {
			int r = i;
			rep(j,i+1,n) if(fabs(A[j][x]) > fabs(A[r][x])) {r=j;}
			if(fabs(A[r][x]) < eps) --i;
			else{
				if(r!=i) rep(j,0,m+1) swap(A[r][j],A[i][j]);
				for (int j = m; j >= x; j--) A[i][j] /= A[i][x];
				rep(j,0,n) if(i!=j && fabs(A[j][x]) >= eps)
					for (int k = m; k >= x; k--)
						A[j][k] -= A[i][k] * A[j][x];
			}
		}
		rep(k,i,n) if(fabs(A[k][m]) >= eps) return -1;
		return m - i;
	}
}
